﻿using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;

namespace EPlantApp.SignalR.Extensions
{
    // 扩展方法类
    public static class DeviceStatusHubExtensions
    {
        public static IServiceCollection AddDeviceStatusHub(this IServiceCollection services)
        {
            services.AddSignalR(options =>
            {
                options.EnableDetailedErrors = true;
                options.KeepAliveInterval = TimeSpan.FromSeconds(15);
            })
                    .AddJsonProtocol(options =>
                    {
                        // 配置JSON序列化（支持日期、枚举等）
                        options.PayloadSerializerOptions.Converters.Add(new JsonStringEnumConverter());
                    });
            return services;
        }
    }
}
